package cn.sc.allinpay.allfavour.business.setting;

import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ToggleButton;

import butterknife.BindView;
import butterknife.OnCheckedChanged;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.base.activity.BaseActivity;

/**
 * 管理员密码修改
 */
public class SettingActivity extends BaseActivity<SettingContract.View, SettingContract.Presenter> implements SettingContract.View {

    @BindView(R.id.tbMobile)
    ToggleButton tbMobile;
    @BindView(R.id.tbQrCode)
    ToggleButton tbQrCode;

    @Override
    protected int layoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void layoutTitle(View top, AppCompatTextView left, AppCompatTextView title, AppCompatTextView right) {
        title.setText("功能设置");
    }

    @Override
    protected SettingContract.Presenter bindPresenter() {
        return new SettingPresenter();
    }

    @Override
    protected void layoutContent(Bundle savedInstanceState) {

    }

    @OnCheckedChanged(R.id.tbMobile)
    void tbMobileChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            presenter.saveMobileStatus("开");
        } else {
            presenter.saveMobileStatus("关");
        }

    }

    @OnCheckedChanged(R.id.tbQrCode)
    void tbQrCodeChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            presenter.saveQrCodeStatus("开");
        } else {
            presenter.saveQrCodeStatus("关");
        }
    }


    @Override
    public void showMobileStatus(String status) {
        if (status.equals("开")) {
            tbMobile.setChecked(true);
        } else {
            tbMobile.setChecked(false);
        }
    }

    @Override
    public void showQrCodeStatus(String status) {
        if (status.equals("开")) {
            tbQrCode.setChecked(true);
        } else {
            tbQrCode.setChecked(false);
        }
    }
}

